<script>
export default {
  name: "Message",
  data() {
    return {
      messages: [
        {id: '001', title: '消息001'},
        {id: '002', title: '消息002'},
        {id: '003', title: '消息003'}
      ]
    }
  }
}
</script>

<template>
  <div>
    <ul>
      <li v-for="msg in messages" :key="msg.id">
        <router-link replace to="/home/message/detail">{{ msg.title }}</router-link>&nbsp;&nbsp;
        <router-link replace :to="`/home/message/detail?id=${msg.id}&title=${msg.title}`">{{ msg.title }} 路径携带query</router-link>&nbsp;&nbsp;

        <router-link replace
            :to="{
                  path:'/home/message/detail',
                  //name:'detail',
                  query:{id:msg.id + 1,title:msg.title},
                 }">{{ msg.title }} 对象携带query</router-link>&nbsp;&nbsp;

        <router-link replace :to="`/home/message/_detail/${msg.id}/${msg.title}`">{{ msg.title }} 路径携带param </router-link>&nbsp;&nbsp;


        <router-link replace
            :to="{
                  //path:'/home/message/_detail',
                  /*既然写了路径，那参数就直接拼在路径上，就不要用params，用了params就得用名称*/
                  name:'_detail',
                  params:{id:msg.id + 1,title:msg.title},
                 }">{{ msg.title }} 对象携带param
        </router-link>
      </li>
    </ul>
    <router-view></router-view>
  </div>
</template>

<style scoped>

</style>